
cc.Class({
    extends: cc.Component,

    properties: {
       message:{
        default:null,
        type: cc.Label
       }
    },

    // onLoad () {},

    clear:function(){
        this.setMessage('');
        this.setOkCallBack(null);
        this.setCancelCallBack(null);
        this.setCloseCallBack(null);
    },

    show:function(mess,okCallBack,cancelCallBack,closeCallBack){
        this.clear();
        this.node.active = true;
        this.setMessage(mess);
        this.setOkCallBack(okCallBack);
        this.setCancelCallBack(cancelCallBack);
        this.setCloseCallBack(closeCallBack);
    },

    hide:function(){
        this.node.active = false;
    },

    onClickClose:function(){
        this.hide();
        if (this.closeCallBack != null) {
            this.closeCallBack;
        }
        cc.director.loadScene('start');
    },

    onClickOk:function(){
        this.hide();
        if (this.okCallBack != null) {
            this.okCallBack;
        }
        cc.director.loadScene('game');
    },

    onClickCancel:function(){
        this.hide();
        if (this.cancelCallBack != null) {
            this.cancelCallBack;
        }
         cc.director.loadScene('start');
    },

    setMessage:function(string){
        this.message.string = string;
    },
    
    setOkCallBack:function(callBack){
        this.okCallBack = callBack;
    },
    setCloseCallBack:function(callBack){
        this.closeCallBack = callBack;
    },
    setCancelCallBack:function(callBack){
        this.cancelCallBack = callBack;
    },
   
});
